package javabasic.threads.CreateThreadMethods;

import javax.lang.model.element.VariableElement;

/**
 * 通过继承Thead创建子线程，主线程和子线程交替执行，无法获取子线程的返回值
 */
public class Method01Extends {
    public static void main(String[] args) {
        //主线程和子线程交替执行
        MyThreadTest myThreadTest = new MyThreadTest();
        myThreadTest.start();
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName()+"====="+i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class MyThreadTest extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName()+"-----"+i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
